package com.ruoyi.web.controller.enterprise;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.enterprise.domain.ProjectConstruction;
import com.ruoyi.enterprise.service.IProjectConstructionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目建设管理Controller
 * 
 * @author yxf
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/enterprise/construction")
public class ProjectConstructionController extends BaseController
{
    @Autowired
    private IProjectConstructionService projectConstructionService;

    /**
     * 查询项目建设管理列表
     */
    //@PreAuthorize("@ss.hasPermi('enterprise:construction:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectConstruction projectConstruction)
    {
        startPage();
        List<ProjectConstruction> list = projectConstructionService.selectProjectConstructionList(projectConstruction);
        return getDataTable(list);
    }

    /**
     * 导出项目建设管理列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:construction:export')")
    @Log(title = "项目建设管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProjectConstruction projectConstruction)
    {
        List<ProjectConstruction> list = projectConstructionService.selectProjectConstructionList(projectConstruction);
        ExcelUtil<ProjectConstruction> util = new ExcelUtil<ProjectConstruction>(ProjectConstruction.class);
        return util.exportExcel(list, "项目建设管理数据");
    }

    /**
     * 获取项目建设管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:construction:query')")
    @GetMapping(value = "/{pcId}")
    public AjaxResult getInfo(@PathVariable("pcId") Long pcId)
    {
        return AjaxResult.success(projectConstructionService.selectProjectConstructionById(pcId));
    }

    /**
     * 新增项目建设管理
     */
    @PreAuthorize("@ss.hasPermi('enterprise:construction:add')")
    @Log(title = "项目建设管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectConstruction projectConstruction)
    {
        return toAjax(projectConstructionService.insertProjectConstruction(projectConstruction));
    }

    /**
     * 修改项目建设管理
     */
    @PreAuthorize("@ss.hasPermi('enterprise:construction:edit')")
    @Log(title = "项目建设管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectConstruction projectConstruction)
    {
        return toAjax(projectConstructionService.updateProjectConstruction(projectConstruction));
    }

    /**
     * 删除项目建设管理
     */
    @PreAuthorize("@ss.hasPermi('enterprise:construction:remove')")
    @Log(title = "项目建设管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pcIds}")
    public AjaxResult remove(@PathVariable Long[] pcIds)
    {
        return toAjax(projectConstructionService.deleteProjectConstructionByIds(pcIds));
    }
}
